package com.yixia.framework.config;

import com.baomidou.mybatisplus.annotation.DbType;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.yixia.framework.dataScope.MybatisPlusPermissionInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MybatisPlus配置类
 */
@Configuration
@MapperScan("com.yixia.*.mapper")
@MapperScan("com.yixia.pea.*.mapper")
public class MybatisPlusConfig {

    /*让mybatisPlus开启分页查询*/
   /* @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
*/

   /* @Autowired
    DataScopePermissionHandler dataScopePermissionHandler;*/

    /**
     * 最新版分页插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

       /* // 添加数据权限插件
        DataPermissionInterceptor dataPermissionInterceptor = new DataPermissionInterceptor();
        // 添加自定义的数据权限处理器
        dataPermissionInterceptor.setDataPermissionHandler(dataScopePermissionHandler);
        interceptor.addInnerInterceptor(dataPermissionInterceptor);*/
        // 数据权限插件（自定义）
        // interceptor.addInnerInterceptor(new MybatisPlusPermissionInterceptor());
        // 分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));

        return interceptor;
    }



}
